package service.impl;

import dao.NewsHeadLineDao;
import dao.NewsUserDao;
import dao.impl.NewsHeadlineDaoImpl;
import dao.impl.NewsUserDaoImpl;
import pojo.NewsHeadline;
import pojo.NewsUser;
import pojo.vo.UserCenterVo;
import service.UserCenterService;
import java.util.List;

public class UserCenterServiceImpl implements UserCenterService {
    private NewsUserDao userDao = new NewsUserDaoImpl();
    private NewsHeadLineDao headlineDao = new NewsHeadlineDaoImpl();

    @Override
    public UserCenterVo getUserCenterInfo(Integer userId) {
        // 获取用户信息
        NewsUser user = userDao.findByUid(userId);
        // 获取用户发布的头条
        List<NewsHeadline> headlines = headlineDao.findByPublisher(userId);

        UserCenterVo vo = new UserCenterVo();
        vo.setUid(user.getUid());
        vo.setUsername(user.getUsername());
        vo.setNickName(user.getNickName());
        vo.setPublishedHeadlines(headlines);
        return vo;
    }
}